package com.wellness.commons.exception;

import com.wellness.commons.message.BaseMessage;

/**
 * 业务层抛出异常类封装，每个业务可以自定义BizMessage继承自BaseMessage，然后throw new BizException(BizMessage)，
 * 业务层捕获此异常后封装成json，返回给gateway
 */
public class BizException extends RuntimeException {

    private int code;
    private String message;

    public BizException() {}

    public BizException(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public BizException(BaseMessage bm) {
        this.code = bm.getCode();
        this.message = bm.getMessage();
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

}
